package hotel.callback.oversea.task;

import com.alibaba.fastjson.JSON;
import hotel.base.oversea.vo.meituan.response.goods.MtHotelGoodsPriceBaseDetailVo;
import hotel.callback.oversea.service.MtHotelGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.List;


@Slf4j
@Component
public class MeituanSaveUpdateGoodsPriceTableTask {
    private String timestamp = "Msugptt"+String.valueOf(System.currentTimeMillis());
    @Autowired
    private MtHotelGoodsService mtHotelGoodsService;
    @Autowired
    private RestTemplate restTemplate;

    //@Async 标识这个方法异步执行，可返回void或Future
    @Async
    public void executeSaveUpdateGoodsPriceTable(List<MtHotelGoodsPriceBaseDetailVo> oneGoodsDatePriceMonth,String thisHotelId,String goodsId,String timestamp){
        ///log.info("MeituanSaveUpdateGoodsPriceTableTask {} >>>>>>>>> 异步线程 更新 价格 库表 oneGoodsDatePriceMonth={} 开始执行时间：{}",timestamp,oneGoodsDatePriceMonth,DateUtil.getNowTime());

        if (null != oneGoodsDatePriceMonth && oneGoodsDatePriceMonth.size() > 0) {
            log.info("MeituanSaveUpdateGoodsPriceTableTask oneGoodsDatePriceMonth={}，thisHotelId={}，goodsId={}", JSON.toJSONString(oneGoodsDatePriceMonth),thisHotelId,goodsId);
            mtHotelGoodsService.saveGoodsPriceInfos(oneGoodsDatePriceMonth,String.valueOf(thisHotelId),goodsId);
        }

    }


}
